package com.ai.platform.system.service.impl;

import com.ai.platform.model.dto.Input;
import com.ai.platform.model.dto.Output;
import com.ai.platform.core.exception.BusinessException;
import com.ai.platform.system.entity.SysPermission;
import com.ai.platform.system.mapper.SysPermissionMapper;
import com.ai.platform.system.service.ISysPermissionService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

/**
 * <p>
 * 权限表 服务实现类
 * </p>
 *
 * @author yeyingsheng
 * @since 2018-05-12
 */
@Service
public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, SysPermission> implements ISysPermissionService {

    @Override
    public void queryPermissionByRoleId(Input input, Output output)  throws BusinessException {
        Integer roleId=Integer.parseInt(input.getValue("roleId"));
        try {
            List<SysPermission> sysPermissionList = baseMapper.queryPermissionByRoleId(roleId);
            output.setData(sysPermissionList);
        } catch (SQLException e) {
            throw new BusinessException("SQL异常:"+e.getMessage());
        }
    }
}
